package com.zcs.android.app.jetpack.ui.login

import androidx.lifecycle.ViewModelProviders
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import androidx.navigation.navOptions

import com.zcs.android.app.jetpack.R
import com.zcs.android.app.jetpack.ui.login.vm.WelcomeViewModel
import kotlinx.android.synthetic.main.welcome_fragment.*

class WelcomeFragment : Fragment() {
    private lateinit var viewModel: WelcomeViewModel

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.welcome_fragment, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        viewModel = ViewModelProvider(this).get(WelcomeViewModel::class.java)
        // TODO: Use the ViewModel

        val options = navOptions {
            anim {
                enter = R.anim.slide_in_right
                exit = R.anim.slide_out_left
                popEnter = R.anim.slide_in_left
                popExit = R.anim.slide_out_right
            }
        }

        btnLogin.setOnClickListener {
            findNavController().navigate(
                R.id.action_welcomeFragment_to_loginFragment,
                null,
                options
            )
        }

        btnReg.setOnClickListener {
            findNavController().navigate(
                R.id.action_welcomeFragment_to_registerFragment,
                null,
                options
            )
        }
    }

}
